package com.kgc.controller;


import com.kgc.common.Result;
import com.kgc.entity.Schedules;
import com.kgc.service.interf.SchedulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/apis/user/schedules")
public class SchedulesController {

    @Autowired
    private SchedulesService schedulesService;

    /**
     * 创建日程
     * @param schedules
     * @return
     */
    @RequestMapping("/add")
    public String addSchedules(Schedules schedules) {
        return schedulesService.addSchedules(schedules) > 0 ? Result.success("0","创建日程成功") : Result.success("400","不合法参数") ;
    }

    /**
     * 修改日程
     * @param schedules
     * @return
     */
    @RequestMapping("/edit")
    public String updateSchedules(Schedules schedules) {
        return schedulesService.updateSchedules(schedules) > 0 ? Result.success("0","修改日程成功") : Result.success("400","不合法参数") ;
    }

    /**
     * 删除日程
     * @param schedules
     * @return
     */
    @RequestMapping("/delById")
    public String deleteSchedules(Schedules schedules) {
        return schedulesService.deleteSchedules(schedules) > 0 ? Result.success("0","删除成功") : Result.success("200","删除失败") ;
    }

}
